const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const { VueLoaderPlugin } = require('vue-loader')
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin')

const common = require('./webpack')

module.exports = merge(common, {
  mode: 'development',
  devtool: false,
  entry: {
    client: './src/entry/entry-client.js'
  },

  optimization: {
    splitChunks: {
      cacheGroups: {
        vendors: {
          chunks: "all",
          test: /[\\/]node_modules[\\/]/,
          name: "vendor",
          minChunks: 1,
          maxInitialRequests: 5,
          minSize: 0,
          priority:100,
        },

        manifest: {
          chunks: 'all',
          name: 'manifest',
          minChunks: 1,
          maxInitialRequests: 5,
          minSize: 0,
          priority:100,
        }
      }
    }
  },

  // output: {
  //   filename: '[name].bundle.js',
  //   chunkFilename: '[name].js',
  //   path: path.resolve('./dist')
  // },

  plugins: [
    // new webpack.optimize.CommonsChunkPlugin({
    //   name: "manifest",
    //   minChunks: Infinity
    // }),
    // 此插件在输出目录中
    // 生成 `vue-ssr-client-manifest.json`。
    new VueSSRClientPlugin()
  ]
})
